﻿module Lab2_1

open Iteration
// Newton's functions for iteration
let newton_enough accuracy x_next x = 
  abs(x_next - x) < accuracy
let newton_step f f' x =
  x - f(x) / f'(x)

// Easy Iteration functions for iteration
let ei_enough q accuracy x_next x = 
  (q / (1.0 - q) ) * abs(x_next - x) <= accuracy

//Lab 2.1 functions
let f x = x * x * x * x - 2.0 * x - 1.0
let f' x = 4.0 * x * x * x - 2.0
let g x = (2.0 * x + 1.0) ** 0.25

let newton_solution accuracy = solve (newton_step f f') (newton_enough accuracy) 1.5
let ei_solution accuracy = solve g (ei_enough 0.2 accuracy) 1.4